﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Diagnostics;

using EnterpriseDT.Net.Ftp;

namespace FreeboxHDVideoPlayer
{
    public class PlayVideoWorker : AbstractWorker
    {
        public string Video
        {
            set;
            get;
        }

        public PlayVideoWorker(string host, int port, string user, string password)
            : base(host, port, user, password)
        {
        }

        protected override void OnDoWork(DoWorkEventArgs e)
        {
            Process vlcProcess = new Process();
            ReportProgress(0, "Démarrage du lecteur");
            vlcProcess.StartInfo.FileName = @"C:\Program Files\VideoLAN\VLC\vlc.exe";
            string videoLocation = "";
            if (VideoLocalCache.Exists(Video))
            {
                videoLocation = VideoLocalCache.GetLocalPath(Video);
            }
            else
            {
                FreeBoxHDFTP ftp = new FreeBoxHDFTP(Host, Port, User, Password);
                videoLocation = ftp.VideoDirFullPath + "/" + Video;
            }
            // start fullscreen
            vlcProcess.StartInfo.Arguments = "-f \"" + videoLocation + "\"";
            vlcProcess.Start();
        }
    }
}
